$(function(){
	getInfo();
})
var sex = '';
var firstname =  '';
var lastname =  '';
var defaul = '';
var phone = '';
var email = '';
var usr = '';
var weblanguage = '';
var invoicelanguage = ''
var octopusNo = '';
//获取个人信息
function getInfo(){
	var arr={
		hf_s_id:"WD11",
		hf_srv_id: "Cv_jcus_adm_inf",
		myasync:true
	};
	getAjaxRequest(arr,function(result){
		if( null == sessionStorage.getItem("iswelcom")){
			dialog('Message', 'Welcome back, '+result.bs_title_id+' '+result.bs_first_name+' '+result.bs_family_name, 1);
			sessionStorage.setItem("iswelcom","no");
		}

		var $dialog = $('#dialog');
		$dialog.show();
		$('.comfirmBtn').html('OK');
		$dialog.find('.comfirmBtn').one('click', function() {
			$dialog.hide();
			$dialog.remove();

		});

		 sex = result.bs_title_id;
		 firstname = result.bs_first_name;
		 lastname = result.bs_family_name;
		 defaul = result.bs_cus_dft_cmt;
		 phone = result.bs_main_phone;
		 email = result.bs_main_email;
		 usr = result.bs_usr_id;
		 weblanguage = result.bs_web_loc_id;
		 invoicelanguage = result.bs_inv_loc_id;
		 octopusNo = result.bs_octopus_no;
		$('#sex').html(sex);
		$('#name').html(firstname+" "+lastname);
		//$('#default').html(defaul);
		$('#phone').html(phone);
		var adderss = result.bvc_address;
		$('#addressName').html(adderss[0].bs_addr_1);
		$('#address1').html(adderss[0].bs_addr_1);
		$('#address2').html(adderss[0].bs_addr_2);
		$('#address3').html(adderss[0].bs_addr_3);
		$('#address4').html(adderss[0].bs_district);

		sessionStorage.setItem("sex",sex);
		sessionStorage.setItem("firstname",firstname);
		sessionStorage.setItem("lastname",lastname);
		sessionStorage.setItem("defaul",defaul);
		sessionStorage.setItem("phone",phone);
		sessionStorage.setItem("email",email);
		sessionStorage.setItem("usr",usr);
		sessionStorage.setItem("weblanguage",weblanguage);
		sessionStorage.setItem("invoicelanguage",invoicelanguage);
		sessionStorage.setItem("octopusNo",octopusNo);
		/*$('#addressName').html(result[i].bs_addr_name);*/
	});

	/*var arr1 = {
		hf_s_id: 'WD11',
		hf_srv_id: 'Cv_jcus_address',
		hs_action_id: 'get_full_list'
	}
	getAjaxRequest(arr1,function(result){
		console.log(result)
		var len = result.length;
		if( len > 0 ) {
				for (var i = 0; i < len; i++) {
					if (result[i].bs_default_ind == 'Y') {
						$('#addressName').html(result[i].bs_addr_name);
						$('#address1').html(result[i].bs_addr_1);
						$('#address2').html(result[i].bs_addr_2);
						$('#address3').html(result[i].bs_addr_3);
						$('#address4').html(result[i].bs_addr_4);
					} else if (result[i].bs_default_ind == 'N') {

					}
				}
		}
	})*/
}


$('.profile').on('tap',function(){
	window.location.href = MPJ.base+'/pages/account/profile/profile.jsp';
})

$('.address-book').on('tap',function(){
	window.location.href = MPJ.base+'/pages/account/receiver/list.jsp';
})
$('.change-pwd').on('tap',function(){
	window.location.href = MPJ.base+'/pages/account/profile/change_pwd.jsp';
})

$('.credit-crad').on('tap',function(){
	window.location.href = MPJ.base+'/pages/account/credit/list.jsp';
})
$('.shop-list').on('tap',function(){
	window.location.href = MPJ.base+'/pages/account/shopping/list.jsp';
})

$('.order-list').on('tap',function(){
	window.location.href = MPJ.base+'/pages/account/order/list.jsp';
})
$('.e-coupons').on('tap',function(){
	window.location.href = MPJ.base+'/pages/account/coupon/list.jsp';
})
$('.contact-preference').on('tap',function(){
	window.location.href = MPJ.base+'/pages/account/my-contact-preference.jsp';
})
$('.logout').on('tap',function(){
	getAjaxRequest({hf_s_id:"WD11",hf_srv_id:"Zv_jcus_logout"},function(result){
		if(result.bs_result==BS_RESULT.OK){
			MPJ.setIsLogin('N');
			sessionStorage.removeItem("iswelcom");
			window.location.href = MPJ.base+'/index.jsp';
		}
	});

})

